package com.damage.admin.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;

@Service
@Slf4j
public class DeploymentService {

    @Autowired
    private RepositoryService repositoryService;

    /**
     * 删除流程部署
     * @param processDefinitionKey
     */
    public void deleteDeploy(String processDefinitionKey){

        List<Deployment> deployments = repositoryService.createDeploymentQuery()
                .processDefinitionKey(processDefinitionKey)
                .list();
        for (Deployment deployment: deployments) {
            repositoryService.deleteDeployment(deployment.getId(),true);
        }
        log.info("删除部署"+processDefinitionKey);

    }
}
